package cn.pms.po;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Month entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_month", schema = "SCOTT")
public class Month implements java.io.Serializable
{
	private static final long serialVersionUID = -8950580744301084713L;
	// Fields
	private Integer id;
	private Year year;
	private cn.pms.type.Month month;
	private Set<Date> dates = new HashSet<Date>(0);
	
	// Constructors
	/** default constructor */
	public Month()
	{}
	
	/** full constructor */
	public Month(Year year, cn.pms.type.Month month, Set<Date> dates)
	{
		this.year = year;
		this.month = month;
		this.dates = dates;
	}
	
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, precision = 32, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_MONTH")
	@SequenceGenerator(name = "SEQ_MONTH", sequenceName = "SEQ_MONTH", allocationSize = 1)
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "yearId")
	public Year getYear()
	{
		return this.year;
	}
	
	public void setYear(Year year)
	{
		this.year = year;
	}
	
	@Column(name = "month", precision = 32, scale = 0)
	@Enumerated(EnumType.ORDINAL)
	public cn.pms.type.Month getMonth()
	{
		return this.month;
	}
	
	public void setMonth(cn.pms.type.Month month)
	{
		this.month = month;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "month")
	public Set<Date> getDates()
	{
		return this.dates;
	}
	
	public void setDates(Set<Date> dates)
	{
		this.dates = dates;
	}
}
